﻿using EPiServer.Core;

namespace TemplateFoundation.UI.WebControls
{
    /// <summary>
    /// Used to add a document selector control when creating user interfaces for the EPiServer UI
    /// </summary>
    public class DocumentSelector : PagePropertyStyleControlBase
    {
        private SimplePropertyDocumentUrlControl _control;

        /// <summary>
        /// Creates a new DocumentSelector control
        /// </summary>
        public DocumentSelector()
        {
            Name = "Document";
            Description = "Select a document on the website";

            _control = new SimplePropertyDocumentUrlControl();
        }

        /// <summary>
        /// Creates the property control to render
        /// </summary>
        public override System.Web.UI.Control CreatePropertyControl()
        {
            return _control;
        }

        /// <summary>
        /// Gets or sets the selected document URL
        /// </summary>
        public string SelectedDocumentUrl
        {
            get
            {
                return _control.SelectedDocumentUrl;
            }
            set
            {
                _control.SelectedDocumentUrl = value;
            }
        }

        /// <summary>
        /// Gets the client ID of the value control
        /// </summary>
        public string ValueControlId
        {
            get
            {
                return _control.ValueControlId;
            }
        }
    }
}
